﻿// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Core.Entities;

/// <summary>
/// 角色
/// </summary>
[Table("Sys_Role")]
[Comment("角色")]
public class SysRole : FullEntityNoIdentity
{
    /// <summary>
    /// 标识
    /// </summary>
    [Comment("标识")]
    [MaxLength(100)]
    public string Code { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    [Comment("名称")]
    [MaxLength(100)]
    public string Name { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [Comment("排序")]
    public int Sort { get; set; }

    /// <summary>
    /// 是否启用
    /// </summary>
    [Comment("是否启用")]
    public bool IsEnable { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [Comment("备注")]
    public string Remark { get; set; }

    #region ref

    //[SugarColumn(IsIgnore = true)]
    //[Navigate(typeof(SysRoleMenu), nameof(SysRoleMenu.RoleId), nameof(SysRoleMenu.MenuId))]//注意顺序
    //public List<SysMenu> Menus { get; set; }

    /// <summary>
    /// 角色菜单
    /// </summary>
    //[SugarColumn(IsIgnore = true)]
    [Navigate(NavigateType.OneToMany, nameof(SysRoleMenu.RoleId))]
    public List<SysRoleMenu> RoleMenus { get; set; }

    /// <summary>
    /// 多对多
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    [Navigate(typeof(SysUserRole), nameof(SysUserRole.RoleId), nameof(SysUserRole.UserId))]//注意顺序
    public List<SysUser> Users { get; set; }

    [SugarColumn(IsIgnore = true)]
    public List<SysUserRole> UserRoles { get; set; }

    #endregion ref
}